/*
 * Copyright 2012 Faculty of Informatics - Masaryk University.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cz.muni.fi.pa165.creatures.dao.web;

import cz.muni.fi.pa165.creatures.model.web.Function;
import cz.muni.fi.pa165.creatures.model.web.Person;
import cz.muni.fi.pa165.creatures.model.web.PersonFunction;
import cz.muni.fi.pa165.creatures.model.web.PersonFunctionPK;
import java.util.List;

/**
 * This interface represents a contract for implementation of the DAO for the
 * {@link cz.muni.fi.pa165.creatures.model.web.PersonFunction} entity.
 *
 * @author xmiklos1
 */
public interface PersonFunctionDAO {

    /**
     * Create a new personFunction.
     *
     * @param personFunction a personFunction to be created
     * @return id of just created personFunction
     */
    PersonFunctionPK create(PersonFunction personFunction);

    /**
     * Updates existing personFunction.
     *
     * @param personFunction a personFunction to be updated
     */
    void update(PersonFunction personFunction);

    /**
     * Removes existing personFunction.
     *
     * @param personFunction a personFunction to be removed
     */
    void remove(PersonFunction personFunction);

    /**
     * Gets a personFunction by its id.
     *
     * @param id id of the wanted personFunction
     * @return the personFunction with the given {@code id} or null if a
     * personFunction doesn't exist
     */
    PersonFunction get(PersonFunctionPK id);

    /**
     * Gets count of all personFunctions.
     *
     * @return number of all personFunctions
     */
    Long getCount();

    /**
     * Gets all personFunctions.
     *
     * @return list of all personFunctions
     */
    List<PersonFunction> getAll();

    /**
     * Removes all existing personFunctions.
     */
    void removeAll();

    /**
     * Checks if a person has some function.
     *
     * @param person person to check
     * @param function function to check
     * @return true if a person has the given function
     */
    boolean hasFunction(Person person, Function function);

    /**
     * Gets a list of functions which belong to a person with specified
     * {@code name}.
     *
     * @param name name of a person to get all functions of
     * @return all functions of a person with specified {@code name}
     */
    List<Function> getFunctions(String name);
}
